package com.demo.controller;

import java.security.Principal;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/admin")
public class AdminController {

	@RequestMapping("/user")
	public String admin(@AuthenticationPrincipal Principal principal, Model model) {
		model.addAttribute("username", principal.getName());
		model.addAttribute("auth", SecurityContextHolder.getContext().toString());
		System.out.println(SecurityContextHolder.getContext().toString());
		return "admin/admin";
	}
}
